package com.cloud.tsp.controller;

import com.cloud.api.constants.StrVo;
import com.cloud.api.domain.tsp.QueryVehicle;
import com.cloud.api.domain.tsp.VinLockStatus;
import com.cloud.api.validgroup.ValidateGroupSelectVin;
import com.cloud.core.util.R;
import com.cloud.log.annotation.Log;
import com.cloud.log.enums.BusinessType;
import com.cloud.log.enums.OperatorType;
import com.cloud.mybatis.domain.TableDataInfo;
import com.cloud.tsp.service.impl.VinLiveServiceImpl;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author haohaibo
 * @since 2024-09-26
 */
@RestController
@RequestMapping("/vin-live")
public class VinLiveController {

    @Resource
    private VinLiveServiceImpl vinLiveService;

    @Tag(name = "v1.0")
    @Operation(summary = "查询车辆vin( tsp位置管理)")
    @PostMapping("/getVinListTsp")
    @Log(title = "实时监控-查询车辆vin", businessType = BusinessType.OTHER, operatorType = OperatorType.MANAGE)
    public TableDataInfo<VinLockStatus> selectVinListTsp(@Validated(ValidateGroupSelectVin.class) @RequestBody @Valid QueryVehicle para) throws IOException {
        return vinLiveService.selectVinListTsp(para);
    }

    @Tag(name = "v1.0")
    @Operation(summary = "查询车辆vin在线状态")
    @PostMapping("/getVinOnlineStatus")
    @Log(title = "实时监控-查询车辆vin在线状态", businessType = BusinessType.OTHER, operatorType = OperatorType.MANAGE)
    public R selectVinOnlineStatus(@RequestBody @Validated StrVo para) throws IOException {
        return R.ok(vinLiveService.selectVinOnlineStatus(para.getId()));
    }
}
